<?php 
    // dd($teacher['id']);
//检测老师是否打卡
$t = $omodel->find()->where(['t_id'=>$teacher['id'],'identity'=>1])->asArray()->all();
// dd($t);
$tag = 1;//表示未签到
if(!empty($t)) {
	$date = date('Y-m-d',time());
	foreach($t as $val) {
		if(substr($val['push_time'],0,10) == $date) {
			$tag = 0;//表示已签到
		}
	}
 }
 ?>
<table class="table table-hovered table-bordered">
	<tr><th>身份</th><th>姓名</th><th>签到打卡</th></tr>
	<tr>
			<td>老师</td>
			<td><?=$teacher['name'];?></td>
			<td>
				<?php 
					if($tag == 1) {
						echo '<a class="a" href="punch?identity=1&cid='.$c_id.'&name='.$teacher["name"].'&person='.$teacher["name"].'&tid='.$teacher["id"].'" class="btn btn-primary">签到</a>';

					}else {
						echo '<a href="javascript:" class="btn">已签到</a>';

					}
				 ?>
					
			</td>

	</tr>
	<?php 
		foreach ($student as $value) {
			$tag1 = 1;
			if(!empty($value)) {
				//检测学生是否已经打卡
				$t1 = $omodel->find()->where(['s_id'=>$value['id'],'identity'=>0])->asArray()->all();
				if(!empty($t1)) {
					$date = date('Y-m-d',time());
					foreach($t1 as $val) {
						if(substr($val['push_time'],0,10) == $date) {
							// dd(substr($val['push_time'],0,10));
							$tag1 = 0;
						}
					}
				}
				// dd($tag1);
	?>
		<tr>
			<td>学生</td>
			<td><?=$value['name'];?></td>
			<td>
				<?php 
					if($tag1 == 1) {
						echo '<a class="a" href="punch?identity=0&sid='.$value['id'].'&cid='.$c_id.'&name='.$value['name'].'&person='.$teacher['name'].'&tid='.$teacher['id'].'" class="btn btn-primary">签到</a>';

					}else {
						echo '<a href="javascript:" class="btn">已签到</a>';

					}
				 ?>
			
			</td>

		</tr>

	<?php
			}
		}
	 ?>

</table>
<script type="text/javascript">
	$(function() {
		$('.a').each(function() {
			$(this).click(function() {
				$(this).removeClass('btn-primary');
				$(this).html('已签到');
			});
		});
	});
</script>